<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var constructMaximumBinaryTree = function (nums) {
      if (nums.length == 0)
        return null
      var big = Math.max(...nums)
      var root = new TreeNode(big)
      root.left = constructMaximumBinaryTree(nums.slice(0, nums.indexOf(big)))
      root.right = constructMaximumBinaryTree(nums.slice(nums.indexOf(big) + 1))
      return root
    };
    console.log(constructMaximumBinaryTree([3, 2, 1, 6, 0, 5]))
  </script>
</body>

</html>